﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CF_DAL_WS.Models;

namespace CF_DAL_WS.DTO
{
    public class ReplyDTO
    {
        public int ID { get; set; }
        public int IDContact { get; set; }
        public string Content { get; set; }
        public string UserReply { get; set; }

        public static ReplyDTO Translate(Reply Entity)
        {
            if (Entity != null)
            {
                var dto = new ReplyDTO
                {
                    ID = Entity.ID,
                    Content = Entity.Content,
                    UserReply = Entity.UserReply
                };
                if (Entity.IDContact != null)
                {
                    dto.IDContact = Entity.IDContact.Value;
                }
                return dto;
            }
            return null;
        }

        public static Reply Reverse(ReplyDTO obj)
        {
            var entity = new Reply
            {
                Content = obj.Content,
                UserReply = obj.UserReply
            };
            if (obj.IDContact != -1)
            {
                entity.IDContact = obj.IDContact;
            }
            return entity;
        }

        public void UpdateEntity(ref Reply entity)
        {
            entity.Content = Content;
            entity.UserReply = UserReply;
            if (IDContact != -1)
            {
                entity.IDContact = IDContact;
            }
        }
    }
}